CC = @gcc
NVCC = @nvcc

# options: -DDEBUG for debugging purposes; -DPERFORMANCE for measuring the completion time
CFLAGS = -Wall -pedantic -DPERFORMANCE -m64

#other previous flags: -lgsl -lgslcblas -lm
LIBS = -ltiff -lcudart -lcula -lcublas

objects = image.o interpolator.o channel.o kernels.o

.PHONY: clean execution tests

# compilation options and dependencies

interpolator: $(objects)
	$(CC) $(LIBS) -L${CUDA_LIB_PATH} -L${CULA_LIB_PATH_64} -o interpolator $(objects)

interpolator.o: interpolator.c image.h channel.h
	$(CC) $(CFLAGS) -I${CUDA_INC_PATH} -I${CULA_INC_PATH} -c -o interpolator.o interpolator.c

image.o: image.c image.h gaussian.h
	$(CC) $(CFLAGS) -c -o image.o image.c

channel.o: channel.c channel.h
	$(CC) $(CFLAGS) -I${CUDA_INC_PATH} -I${CULA_INC_PATH} -c -o channel.o channel.c

kernels.o: kernels.cu gaussian.h
	$(NVCC) -Xptxas -v -m64 -I${CUDA_INC_PATH} -c -o kernels.o kernels.cu

# other targets

clean:
	@echo "\nDeleting old files"
	@-rm -f ./interpolator $(objects) *~ ./Debug/*.tiff

execution:
	@./interpolator 256 256 100

tests:
	@./interpolator 128 128 1000
	@./interpolator 256 256 1000
	@./interpolator 512 512 1000
	@./interpolator 1024 1024 1000
	@./interpolator 2048 2048 1000

